import {
  IsEnum,
  IsNotEmpty,
  IsOptional,
  IsString,
  Length,
  Matches,
} from 'class-validator';
import { PlatformType, ProjectType } from '../entities/sourcemap.entity';

export class CreateSourcemapDto {
  @IsEnum(PlatformType, { message: '无效的平台类型' })
  platformType: PlatformType;

  @IsOptional()
  @IsString({ message: '客户名称必须是字符串' })
  @Length(2, 100, { message: '客户名称长度应在2-100个字符之间' })
  customerName?: string;

  @IsEnum(ProjectType, { message: '无效的项目类型' })
  projectType: ProjectType;

  @IsNotEmpty({ message: '版本号不能为空' })
  @IsString({ message: '版本号必须是字符串' })
  @Matches(/^\d+\.\d+\.\d+$/, {
    message: '版本号格式必须是 x.y.z，例如：3.11.1',
  })
  version: string;
}
